package OOPAndMultiThreadArchiveManager.Server.Tools;

import java.io.IOException;
import java.util.Properties;

public class PropertiesLoader {
    public static int ConnectPort = 0;
    public static int FileDownloadPort = 0;
    public static int FileUploadPort = 0;
    public static String SaveFilesPath = "";
    public static String JDBC_DRIVER = "";
    public static String DataBaseURL = "";
    public static String DataBaseUser = "";
    public static String DataBasePassword = "";

    public void getProperties() {
        try {
            var inputStream = this.getClass().getClassLoader().getResourceAsStream("Server.properties");
            var properties = new Properties();
            properties.load(inputStream);
            ConnectPort = Integer.parseInt(properties.get("ConnectPort").toString());
            FileDownloadPort = Integer.parseInt(properties.get("FileDownloadPort").toString());
            FileUploadPort = Integer.parseInt(properties.get("FileUploadPort").toString());
            SaveFilesPath = properties.get("FilePath").toString();
            JDBC_DRIVER = properties.get("JDBC_DRIVER").toString();
            DataBaseURL = properties.get("DataBaseURL").toString();
            DataBaseUser = properties.get("DataBaseUser").toString();
            DataBasePassword = properties.get("DataBasePassword").toString();
        } catch (IOException e) {
            System.out.println("Properties error.");
        }
    }
}
